import { usePageResponseSuccess } from '~/utils/response';

function generateMockDataList(count: number) {
  const dataList = [];
  for (let i = 0; i < count; i++) {
    const timestamp = new Date().getTime();
    const random = parseInt(Math.random() * 1000);
    const dataItem = {
      id:timestamp + '' + random,
      name:"张" + random,
      role:"管理员",
      sex:"女",
      age:parseInt(Math.random() * 100),
      address:"未知"
    };
    dataList.push(dataItem);
  }
  return dataList;
}
const mockData = generateMockDataList(100);

/**
 * 请求示例 http://127.0.0.1:5320/api/mock/mock1
 */

export default eventHandler(async (event) => {
  const { page, pageSize } = getQuery(event);
  const listData = structuredClone(mockData);
  await sleep(600);
  return usePageResponseSuccess(page as string, pageSize as string, listData);
});